package functions.ems_claim;

import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.crc.mam.PropertiesUtil;

import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;
/**
 * 
 * @author zhuyi
 * 发起付款准备查询列表分页以及排序
 */
public class FindInitPaymentPreparationByCondition{
	private static Logger logger = LoggerFactory.getLogger(FindInitPaymentPreparationByCondition.class);
	String payRequestClaimNo;
	String fileName;
	String orderBy;
	String currentPage;
	String pageSize;
	String result;
	
	
	public FindInitPaymentPreparationByCondition(String fileName,String orderBy,String payRequestClaimNo) {

		this.fileName = fileName;
		this.orderBy = orderBy;
		this.payRequestClaimNo=	payRequestClaimNo;
	}
	
	

	/**
	 * 通过付款申请单号查询付款申请
	 */
	public void findInitPaymentPrepByCondition() {
		logger.info("通过付款申请单号"+payRequestClaimNo+"查询---发起付款准备查询列表-----start---");
		String params="{\"page\":{\"currentPage\":1,\"pageSize\":10,\"recordCount\":11},"
				+ "\"params\":{\"payRequestOuCode\":\"\",\"vendorName\":\"\",\"startDueToDate\":\"\","
				+ "\"endDueToDate\":\"\",\""+payRequestClaimNo+"\":\"\",\"invoiceNo\":\"\","
				+ "\"applyEmployeeName\":\"\",\"startCreateTime\":\"\",\"endCreateTime\":\"\","
				+ "\"payMentMode\":\"\",\"vendorType\":\"\",\"startApplyAmount\":\"\","
				+ "\"endApplyAmount\":\"\",\"startDraftAmount\":\"\",\"endDraftAmount\":\"\","
				+ "\"applyStatus\":\"\",\"projectCode\":\"\",\"currency\":\"\"},"
				+ "\"sortDTO\":{\"fieldName\":\""+fileName+"\",\"orderBy\":\""+orderBy+"\"}}";
		
		String url= Constants.FIND_INIT_PAYMENT_PREPARATION_BY_CONDITION_URL;
		
		try {
			result = HttpHelper.post(params, url);
			logger.info("findInitPaymentPrepByCondition"+result);
			try {
				JSONObject jsonObject= new JSONObject(result);
				JSONArray jsonArray = jsonObject.getJSONArray("list");
				JSONObject jsonString = jsonArray.getJSONObject(0);
				
				int payRequestLineId=0;
				try {
					payRequestLineId=jsonString.getInt("payRequestLineId");
				} catch (Exception e) {
					// TODO: handle exception
				}
				int payRequestClaimId=0;
				try {
					payRequestClaimId=jsonString.getInt("payRequestClaimId");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String payRequestClaimNo="";
				try {
					payRequestClaimNo= jsonString.getString("payRequestClaimNo");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String payRequestOuCode="";
				try {
					payRequestOuCode=jsonString.getString("payRequestOuCode");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String payRequestOuName="";
				try {
					payRequestOuName=jsonString.getString("payRequestOuName");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorCode="";
				try {
					vendorCode=jsonString.getString("vendorCode");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorName="";
				try {
					vendorName=jsonString.getString("vendorName");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorSite="";
				try {
					vendorSite=jsonString.getString("vendorSite");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorAccountNo="";
				try {
					vendorAccountNo=jsonString.getString("vendorAccountNo");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorAreaCode="";
				try {
					vendorAreaCode=jsonString.getString("vendorAreaCode");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String vendorBlankCode="";
				try {
					vendorBlankCode=jsonString.getString("vendorBlankCode");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String invoiceNo="";
				try {
					invoiceNo=jsonString.getString("invoiceNo");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String applyEmployeeNo="";
				try {
					applyEmployeeNo=jsonString.getString("applyEmployeeNo");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String applyAmount="";
				try {
					applyAmount=jsonString.getString("applyAmount");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String payType="";
				try {
					payType=jsonString.getString("payType");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String currencyType="";
				try {
					currencyType=jsonString.getString("currencyType");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String status="";
				try {
					status=jsonString.getString("status");
				} catch (Exception e) {
					// TODO: handle exception
				}
				String rhBankCode="";
				try {
					rhBankCode=jsonString.getString("rhBankCode");
				} catch (Exception e) {
					// TODO: handle exception
				}
				int invoiceAmount=0;
				try {
					invoiceAmount=jsonString.getInt("invoiceAmount");
				} catch (Exception e) {
					// TODO: handle exception
				}
      
				//System.out.println(jsonObject.toString());
				//int total= jsonObject.getInt("total");
				//System.out.println(total+"条数据");
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		} catch (Exception e) {
			// TODO: handle exception
		}
		logger.info("通过付款申请单号"+payRequestClaimNo+"查询---发起付款准备查询列表-----end---");
	}


	
}
